<template>
	<view class="main_my">
		<view class="" v-if="myAvatar">
			<u-avatar size="120" :src="myAvatar"></u-avatar>
		</view>
		<view class="avatar" v-if="nickName && avatar.length == 0">
			<view class="av_img">
				<view class="default_letter" :class="{man:sex == '0',women:sex !== '0'}">
					{{nickName.slice(0,1)}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	/**
	 * 1.啥也不传显示默认logo
	 * 2.只传头像显示头像
	 * 3.不传头像，并且有name和sex时。显示姓名第一个字头像 0男 1女
	  :avatar="avatar"  :nickName="nickName" :sex="sex"
	**/
	export default {
		props:{
			nickName:{
				default:'',
				required:false
			},
			avatar:{
				default:'',
				required:false
			},
			sex:{
				default:'0',
				required:false
			},
		},
		data() {
			return {
				//defalutImg: require('@/static/img/Login_logo.png')  //默认logo
			}
		},
		computed:{
			myAvatar(){
				if(this.avatar){ //有头像直接显示头像
					return this.defalutImg = this.avatar
				}
				if(!this.nickName){ //没有nickname，说明没登录，显示默认logo
					return this.defalutImg = require('@/static/img/Login_logo.png') 
				}else{ //有昵称说明登陆过，到这一步说明没有些，就显示
					return ''
				}
			}
		},
		methods: {

		},
	}
</script>

<style lang="scss" scoped>
.main_my{
	//background-color: #F8F8F8;
	.avatar {
		//border-bottom: 1px solid rgb(228, 231, 237);
		border-bottom: 1px solid #F8F8F8;
		display: flex;
		align-items: center;
	
		.aTitle {
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #212121;
			line-height: 38rpx;
		}
	
		.av_img {
			flex: 1;
			//padding-left: 100rpx;
		//	padding-top: 30rpx;
			padding-bottom: 30rpx;
			display: flex;
			justify-content: flex-end;
			align-items: center;
	
			.img_box {
				margin-right: 10rpx;
				// width: 120rpx;
				// height: 120rpx;
			}
	
			.default_letter {
				width: 120rpx;
				height: 120rpx;
	
				border-radius: 50%;
				display: flex;
				align-items: center;
				justify-content: center;
			}
	
			.man {
				font-family: PingFang SC, PingFang SC;
				font-weight: 800;
				font-size: 60rpx;
				color: #4DC0D9;
				line-height: 70rpx;
				background-color: #F4FDFF;
			}
	
			.women {
				font-family: PingFang SC, PingFang SC;
				font-weight: 800;
				font-size: 60rpx;
				color: #F1280D;
				line-height: 70rpx;
				background-color: #FFEBEB;
			}
		}
	}
}
</style>